<?php
/*=====================================================================
  (C)2007 BeaBo Japan by Hiroki Seike
  http://beabo.net/
=====================================================================*/
if (!defined('XOOPS_ROOT_PATH')) exit();

	// delete bookmark using Ajax delete
	function deleteBookmark($bId = NULL) {
		$retArray = array();
		$root =& XCube_Root::getSingleton();
		$db =& $root->mController->mDB;
		// get image
		$sql = sprintf("SELECT image FROM `%s` WHERE `bId` ='%s' LIMIT 1", $db->prefix("scuttle_bookmarks"), $bId );
		$result = $db->query($sql) ;
		while (list($image) = $db->fetchRow($result)) {
			if ($image <> '') {
				// delete image
				$filename = XOOPS_UPLOAD_PATH . "/scuttle/" . $image ;
				if (file_exists($filename)) {
					unlink($filename);
				}
			}
		}
		// delete tag
		$sql = sprintf("DELETE FROM `%s` WHERE `bId`='%s'", $db->prefix("scuttle_tags"), $bId );
		$db->queryF($sql) ;
		// delete bookmark
		$sql = sprintf("DELETE FROM `%s` WHERE `bId`='%s'  LIMIT 1", $db->prefix("scuttle_bookmarks"), $bId );
		return $db->queryF($sql) ;
	}


?>